<template>
  <div v-if="show" class="modal-bg" @click="hide">
    <div class="fadeInLeft animated modal" @click="stopPropagation" :style="{width:width||'400px'}">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  model: {
    prop: 'show',
    event: 'change'
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    width: {
      type: String,
      default: ''
    }
  },
  methods: {
    hide() {
      this.$emit('change')
    },

    stopPropagation(e) {
      e.stopPropagation()
    }
  }
}
</script>

<style lang="scss" scoped>
.modal-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;

  .modal {
    // width: 400px;
    background: #fff;
    height: 100%;
  }
}
</style>